package com.zyuc.spark.transform

import java.io.FileReader
import java.util.Properties

import org.apache.commons.cli.{GnuParser, Option, Options}

/**
  * Created by zhoucw on 18-8-10 下午3:03.
  */
object TransFormApp {

  def readProperties(fileName:String) = {

   val properties = new Properties()
    properties.load(new FileReader(fileName))

    val sets = properties.entrySet()
    val iter = sets.iterator()
    while(iter.hasNext){
      println("netxt")
      val set = iter.next()
      println("key:" + set.getKey + ", value:" + set.getValue)
    }


  }

  def main(args: Array[String]): Unit = {

    val options = new Options

    var option = new Option("n", "name", true, "the name of this agent")
    option.setRequired(true)
    options.addOption(option)

    option = new Option("f", "conf-file", true, "the name of this conf-file")
    option.setRequired(true)
    options.addOption(option)

    val parser = new GnuParser
    val commandLine = parser.parse(options, args)

    val agentName = commandLine.getOptionValue('n')
    val fileName = commandLine.getOptionValue('f')

    readProperties(fileName)

    println("agentName:" + agentName + ", fileName:" + fileName)


  }
}
